import { reqDetailInfo } from '@/network';


const state = {
    detailInfo: {},
}

const actions = {
    async getDetailInfo({commit},skuId){
        // console.log('2',content);
        const result = await reqDetailInfo(skuId);
        // console.log(result,'111');
        if (result.code === 200) {
            commit('RECEIVE_DETAILINFO',result.data);
        } 
    }
}

const mutations = {
    RECEIVE_DETAILINFO(state,detailInfo) {
        state.detailInfo = detailInfo;
    }
}

const getters = {
    categoryView(state) {
        return state.detailInfo.categoryView || {}
    },
    skuInfo(state) {
        return state.detailInfo.skuInfo || {}
    },
    spuSaleAttrList(state) {
        return state.detailInfo.spuSaleAttrList || []
    }
}

export default {
    state,
    actions,
    mutations,
    getters
}